home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / c / bc_pas_1.zip / PAN2OP.C < prev    next >
C/C++ Source or Header  |  1992-07-17  |  3KB  |  125 lines

  1. ;
  2. ;   /*\
  3. ;---|*|----====< Stereo2OP >====----
  4. ;---|*|
  5. ;---|*| This program demonstrates how to perform 11 voice stereo with
  6. ;---|*| panning on the OPL3. This uses MELODIC mode makes the voice pan
  7. ;---|*| from left to right.
  8. ;---|*|
  9. ;   \*/
  10.  
  11.  
  12. #include <stdio.h>
  13.  
  14.  
  15.  
  16. ;   /*\
  17. ;---|*|----====< main >====----
  18. ;   \*/
  19.  
  20. main()
  21. {
  22.  
  23.     // initialize the FM interface
  24.  
  25.         mvFMInitMode(1);                // 1 = split mode
  26.  
  27.     // Load the FM patch
  28.  
  29.         outdual3812 (0x20, 0x01, 0x01);     // multiple = 1
  30.  
  31.         outdual3812 (0x40, 0x1F, 0x00);     // left volume is off
  32.  
  33.         outdual3812 (0x60, 0xF0, 0xF0);     // Attack  = F, Decay = 0
  34.  
  35.         outdual3812 (0x80, 0xF1, 0xF1);     // Sustain = F, Release = 1
  36.  
  37.         outdual3812 (0xA0, 0x6B, 0x6B);     // frequency = 16Bh
  38.  
  39.         outdual3812 (0xC0, 0x11, 0x21);     // Left connect = 11h, right = 21h
  40.  
  41.         outdual3812 (0xB0, 0x35, 0x35);     // KEY-ON=1, block=5, f(9,10)=01
  42.  
  43.         outdual3812 (0xB0, 0x15, 0x15);     // KEY-ON=0, block=5, f(9,10)=01
  44.  
  45.     // rotate the sound
  46.  
  47.         pancircle();
  48.         pancircle();
  49.         pancircle();
  50.         pancircle();
  51.  
  52. }
  53.  
  54.  
  55. ;   /*\
  56. ;---|*|----====< pancircle >====----
  57. ;---|*|
  58. ;---|*| This routine moves the volumes up and down
  59. ;---|*|
  60. ;   \*/
  61.  
  62. pancircle()
  63. {
  64.  
  65.     // switch to the left side
  66.  
  67.         delay();
  68.         outdual3812 (0x40, 0x0F, 0x01);     // leftvol = 0x0F, right = 0x01
  69.         delay();
  70.         outdual3812 (0x40, 0x07, 0x03);     // leftvol = 0x0F, right = 0x01
  71.         delay();
  72.         outdual3812 (0x40, 0x03, 0x07);     // leftvol = 0x0F, right = 0x01
  73.         delay();
  74.         outdual3812 (0x40, 0x01, 0x0F);     // leftvol = 0x0F, right = 0x01
  75.         delay();
  76.         outdual3812 (0x40, 0x00, 0x1F);     // leftvol = 0x0F, right = 0x01
  77.  
  78.     // switch to the right side
  79.  
  80.         delay();
  81.         outdual3812 (0x40, 0x01, 0x0F);     // leftvol = 0x0F, right = 0x01
  82.         delay();
  83.         outdual3812 (0x40, 0x03, 0x07);     // leftvol = 0x0F, right = 0x01
  84.         delay();
  85.         outdual3812 (0x40, 0x07, 0x03);     // leftvol = 0x0F, right = 0x01
  86.         delay();
  87.         outdual3812 (0x40, 0x0F, 0x01);     // leftvol = 0x0F, right = 0x01
  88.         delay();
  89.         outdual3812 (0x40, 0x1F, 0x00);     // leftvol = 0x0F, right = 0x01
  90. }
  91.  
  92. ;   /*\
  93. ;---|*|----====< delay >====----
  94. ;---|*|
  95. ;---|*| This routine delays for up to three clock tics. Each clock tic
  96. ;---|*| occurs at a rate of 18.2 times per second.
  97. ;---|*|
  98. ;   \*/
  99.  
  100. delay()
  101. {
  102.  
  103.         _asm {
  104.             push    si
  105.             mov     si,3        ; wait up to 3 tics in time
  106.  
  107.             mov     ah,0        ; get the current clock tic
  108.             int     1ah
  109.             mov     bx,dx       ; bx holds the original time
  110.         ;
  111.         delay05:
  112.             mov     ah,0
  113.             int     1ah
  114.             cmp     bx,dx       ; wait while two tics are equal
  115.             jz      delay05
  116.  
  117.             mov     bx,dx       ; update the original time
  118.             dec     si          ; loop until our tic count expires
  119.  
  120.             jnz     delay05
  121.         }
  122. }
  123.  
  124.  
  125.